function paddingNum(num) {
  let str = num.toString();
  let arr = str.split(".");
  let numarr = arr[0].split("");
  let resStr = "";
  let t = 0;
  for (let i = numarr.length - 1; i >= 0; i--) {
    t++;
    if (t % 4 == 0) {
      resStr += ",";
      i++;
    } else resStr += numarr[i];
  }
  resStr=resStr.split("").reverse();
  let res = resStr + "." + arr[1];
  return res;
}
let num = 12222.22;
let res = paddingNum(num);
console.log(res);
